package com.qj.daibei.controller;

import com.qj.daibei.pojo.Payment;
import com.qj.daibei.pojo.User;
import com.qj.daibei.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Date;

/**
 * author wml
 * Created on 2021/10/4 21:11
 */
@Controller
public class PaymentController {

    @Autowired
    private PaymentService paymentService;

    @RequestMapping("/insertPayment")
    public ResponseEntity<String> insertPayment(Payment payment, HttpServletRequest request) throws IOException {
        HttpSession session = request.getSession(false);
        if (session == null) {
            return new ResponseEntity<String>("noSession", HttpStatus.OK);
        }
        User user = (User) session.getAttribute("loginUser");
        payment.setUserId(user.getUserId());
        payment.setLendingTime(new Date());

        System.out.println(payment.toString());
//        int result = dataFilingService.updateDataFiling(dataFiling);
        return new ResponseEntity<String>("ok", HttpStatus.OK);
    }
}
